package jdbc;

import java.nio.file.Watchable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo3 {
    public static void main(String[] args) {
        try (Connection connection =  DBUtil.getConnection())
        {
            Statement state =  connection.createStatement();
            String sql = "SELECT id,name,age,salary*12 sal,comm,gender " +
                    "FROM teacher";
            System.out.println(sql);
            ResultSet rs =  state.executeQuery(sql);
            while (rs.next()){
                int id = rs.getInt("id");
                String name = rs.getString("name");
                int age = rs.getInt("age");
                int sal = rs.getInt("sal");
                int comm = rs.getInt("comm");
                String gender = rs.getString("gender");
                System.out.println(id+","+name+","+age+","+sal+","+comm+","+gender);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
